import syscall

fn main():void! {
    string path = './asserts/test_mkdir'
    string path2 = './asserts/test_rename'

    syscall.mkdir(path, 0755) catch err {
        print('mkdir err: ', err.msg(), '\n')
    }

    // 读取目录进行检查
    var st = syscall.stat(path)
    print('st.mode: ', st.mode, '\n')

    // 修改目录名称 test_rename
    syscall.rename(path, path2)
    println('rename success')

    var st2 = syscall.stat(path2)
    print('st2.mode: ', st2.mode, '\n')

    // chmod 为 0744
    syscall.chmod(path2, 0744)

    st2 = syscall.stat(path2)
    print('st2.mode: ', st2.mode, '\n')

    // rmdir
    syscall.rmdir(path2)
    println('rmdir success')
    var _ = syscall.stat(path2) catch err {
        print('stat err: ', err.msg(), '\n')
        syscall.stat_t{}
    }

    var pid = syscall.getpid()
    if pid > 0 {
        println('getpid success')
    }

    var ppid = syscall.getppid()
    if ppid > 0 {
        println('getppid success')
    }

    // get cwd
    var cwd = syscall.getcwd()
    if cwd.len() > 0 {
        println('getcwd success')
    }
}